<?php
class retrieve_metadata_admin extends retrieve_base{

	private $module_display_options 	= array();
	/*************************************************************************************************************************
	* function produces abstract structure of modules db structure
	*
	* used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*************************************************************************************************************************/
	function create_table(){
		$tables = array();
		/*************************************************************************************************************************
		* Table structure for table 'metadata_details'
		*
		* Payment details for different paysysttems differ greatly this table holds the key pairs of variable/value
		*************************************************************************************************************************/
		$fields = array(
			array("md_identifier"		,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
			array("md_link_id"			,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
			array("md_link_group_id"	,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
			array("md_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
			array("md_uri"				,"varchar (255)"			,"NOT NULL"	,"default ''"),
			array("md_title"			,"varchar (255)"			,"NOT NULL"	,"default ''"),
			array("md_module"			,"varchar (255)"			,"NOT NULL"	,"default ''"),
			array("md_description"		,"text"						,"NOT NULL"	,"default ''"),
			/*************************************************************************************************************************
			* shopping cart information
			*************************************************************************************************************************/
			array("md_price"			,"double"					,"NOT NULL"	,"default '0'"),
			array("md_discount"			,"double"					,"NOT NULL"	,"default '0'"),
			array("md_weight"			,"double"					,"NOT NULL"	,"default '0'"), // in kg
			array("md_vat"				,"small integer"			,"NOT NULL"	,"default '0'"), // charge vat (1,0) true/false
			array("md_quantity"			,"signed integer"			,"NOT NULL"	,"default '-1'"),
			array("md_canbuy"			,"small integer"			,"NOT NULL"	,"default '0'"), // can buy item (1,0) true/false
			/*************************************************************************************************************************
			* metadata Date information
			* 
			* creation date  :: is the creation date of the content
			* modified date  :: is the date the content was last modified.
			* review date    :: is the date that this content has to be reviewed.
			* publish date	 :: is the date that this content was published to the site.
			* remove date    :: is the date that this content should be automatically removed from the site.
			* available date :: is the date that this content will be avaliable on the site can be equal to or greater than the publish date 
			*************************************************************************************************************************/
			array("md_date_creation"		,"datetime"			,""			,"default ''"),
			array("md_date_modified"		,"datetime"			,""			,"default ''"),
			array("md_date_review"			,"datetime"			,""			,"default ''"),
			array("md_date_publish"			,"datetime"			,""			,"default ''"),
			array("md_date_remove"			,"datetime"			,""			,"default ''"),
			array("md_date_available"		,"datetime"			,""			,"default ''")
		);
		$primary ="md_identifier";
		$tables[count($tables)] = array("metadata_details", $fields, $primary);
		/*************************************************************************************************************************
		* Table structure for table 'metadata_properties'
		*
		* Payment details for different paysysttems differ greatly this table holds the key pairs of variable/value
		* the pap_identifier is mapped to the pad_identifier field
		*************************************************************************************************************************/
		$fields = array(
			array("mdp_identifier"		,"unsigned integer"			,"NOT NULL"	,"default '0'"), // link to Metadata record
			array("mdp_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
			array("mdp_property"		,"varchar (255)"			,"NOT NULL"	,"default ''","key"),
			array("mdp_value"			,"varchar (255)"			,"NOT NULL"	,"default ''","key")
		);
		$primary ="";
		$tables[count($tables)] = array("metadata_properties", $fields, $primary);
		/*************************************************************************************************************************
		* Table structure for table 'metadata_keywords'
		*
		* keywords are stored once for all clients
		*************************************************************************************************************************/
		$fields = array(
			array("mdk_identifier"		,"unsigned integer"			,"NOT NULL"	,"default '0'"), // primary key
			array("mdk_value"			,"varchar (255)"			,"NOT NULL"	,"default ''","key")
		);
		$primary ="";
		$tables[count($tables)] = array("metadata_keyword", $fields, $primary);
		/*************************************************************************************************************************
		* Table structure for table 'metadata_keywords_relationship'
		*
		* keywords are stored once for all clients
		*************************************************************************************************************************/
		$fields = array(
			array("mdkr_identifier"		,"unsigned integer"			,"NOT NULL"	,"default '0'"),	// metadata record
			array("mdkr_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'"), 	// client owner
			array("mdkr_keyword"		,"unsigned integer"			,"NOT NULL"	,"default '0'"), 	// client owner
			array("mdkr_count"			,"unsigned integer"			,"NOT NULL"	,"default '0'")		// keyword identifier
		);
		$primary ="";
		$tables[count($tables)] = array("metadata_keyword_relationship", $fields, $primary);
		
		return $tables;
	}
}
?>